//
//  LCPlaylist.m
//  LC
//
//  Created by admin on 16/12/16.
//  Copyright © 2016年 admin. All rights reserved.
//

#import "LCPlaylist.h"
#import "JKSongsMessStatus.h"

@implementation LCPlaylist {
    NSMutableArray<JKSongsMessStatus *>  *_songs;
}

- (instancetype)init
{
    self = [super init];
    if (self) {
        _songs = [NSMutableArray new];
    }
    return self;
}

#pragma mark - 歌曲管理 -
// 获取播放列表的所有歌曲
- (NSArray<JKSongsMessStatus *>*)allSongs {
    return _songs;
}

// 删除歌曲
- (void)removeSongAtIndex:(NSUInteger)index {
    // 1. 判断参数有效性
    if(_songs.count == 0 || index >= _songs.count) {
        return;
    }
    
    // 2. 具体业务逻辑
    [_songs removeObjectAtIndex:index];
}

// 添加歌曲
- (void)addSong:(JKSongsMessStatus *)song {
    if(song == nil) return;
    
    [_songs addObject:song];
}
// 添加歌曲 到 当前播放的位置de后面
- (void)addSongSelectedIndexLater:(JKSongsMessStatus *)song {
    if(song == nil) return;
    if (_LCPlayer.songs) {
        [_songs insertObject:song atIndex:_LCPlayer.selectedIndex + 1];
    }else{
        [self addSong:song];
    }
}

@end
